package com.qf.pojo;

import org.springframework.beans.factory.BeanNameAware;

import javax.annotation.PostConstruct;

/**
 *
 * 测试对象的生命周期的
 * @author lixu
 */
public class LiftCycleDemo implements BeanNameAware {

    //依赖注入
    private User user;
    public void setUser(User user) {
        System.out.println("LiftCycleDemo:依赖注入");
        this.user = user;
    }

    public LiftCycleDemo() {// user ==null  null.getSex
        System.out.println("LiftCycleDemo:构造器:");
    }
    //初始化
    public void init(){
        System.out.println("LiftCycleDemo:初始化");
    }
    //销毁
    public void destroy(){
        System.out.println("LiftCycleDemo:销毁");
    }

    //BeanNameAware
    @Override
    public void setBeanName(String s) {
        System.out.println("LiftCycleDemo:BeanNameAware:用户的性别：" + user.getSex());
    }

    /**
     * 十七：注解开发
     */
 /*   @PostConstruct
    public void initCustom(){
        System.out.println("LiftCycleDemo:initCustom");
    }*/
}
